<?
//        if($errorMsg) echo "<b><br><div class=errormsg>$errorMsg</div><br></b><br>";
//        $errorMsg = "";
        if (isset($ren_complete)) echo "<b><br><div class=errormsg>$ren_complete</div><br></b><br>";

	if ($errorMsg) {
	include_once('errorMsg.html');
	}
	if ($okMsg) {
	include_once('okMsg.html');
	}
	else{
	}	
//	if (isset($ren_complete)) {
//	$okMsg = translate('ren_complete');
//	include_once('okMsg.html');
//  echo "<b><br><div class=errormsg>$ren_complete</div><br></b><br>";
//	}
?> 
<table width="500" border="0" cellspacing="0" cellpadding="0">
  <tr> 
    <td><font class="text"><b><?=translate('man_renew');?></b></font></td>
  </tr>
</table>
<br>
<TABLE border=1 class='bTable' cellspacing='0' width='540'>
<?
  $data = list_reseller_clients_for_renew($id);
	$params[sid]=$sid;
	$params[action]='renewClient';
	
       if(is_array($data)){
                       echo "<TR>
                               <TH>".translate('date')."</TH>
                               <TH>".translate('client')."</TH>
                               <TH>".translate('sale_type')."</TH>
                               <TH>".translate('info')."</TH>
                               <TH>".translate('status')."</TH>
                               <TH>".translate('price')."</TH>
				<th>".translate('renew')."</th>
                             </TR>
                       ";
		$cur_client='';
		foreach($data as $d){
			if($cur_client!=$d[client]){
				if(is_array($temp) && count($temp)>=1){
					$counter=0;
					foreach($temp as $t){
						$counter++;
						if($counter==1){
							echo "<TR>
							       <TD> $t[date]</TD>
							       <TD> $t[client]</TD>
							       <TD> $t[type]</TD>
							       <TD>&nbsp; $t[sale_data]</TD>
							       <TD> $t[state]</TD>
								<TD> $t[price]</TD>
								<td rowspan=$rowspan><a href='$url'>".translate('renew')."</a></td>
							      </TR>
								";

						}else {
							echo "<TR>
						       <TD> $t[date]</TD>
						       <TD> $t[client]</TD>
						       <TD> $t[type]</TD>
						       <TD>&nbsp; $t[sale_data]</TD>
						       <TD> $t[state]</TD>
							<TD> $t[price]</TD>
						      </TR>
							";
						}
					}
				}
				$rowspan=0;
				$temp=array();
			}
			$temp[]=$d;
			$params[client]=$d[client];
			$url="$baseURL/?".encode_params($params);
			$rowspan++;
			$cur_client=$d[client];
		}
		if(is_array($temp) && count($temp)>=1){
			$counter=0;
			foreach($temp as $t){
				$counter++;
				if($counter==1){
					echo "<TR>
					       <TD> $t[date]</TD>
					       <TD> $t[client]</TD>
					       <TD> $t[type]</TD>
					       <TD>&nbsp; $t[sale_data]</TD>
					       <TD> $t[state]</TD>
						<TD> $t[price]</TD>
						<td rowspan=$rowspan><a href='$url'>".translate('renew')."</a></td>
					      </TR>
						";

				}else {
					echo "<TR>
				       <TD> $t[date]</TD>
				       <TD> $t[client]</TD>
				       <TD> $t[type]</TD>
				       <TD>&nbsp; $t[sale_data]</TD>
				       <TD> $t[state]</TD>
					<TD> $t[price]</TD>
				      </TR>
					";
				}
			}
		}

        }
        else{
						 $errorMsg = translate('empty_list');
						 include_once('errorMsg.html');
//           echo "<TR><TD>".translate('empty_list')."</TD></TR>";
        }
?>
</TABLE>
